/**
 * 指令公共接口
 */

import Axios from '@/utils/request';

// 根据请求编号、条目entryKey、请求组编号查询指令明细
export function getInstructionResultBranchDetail(requestId, entryKey, groupCode, stockCode, needDetail?: boolean): Promise<any> {
    const param = {
        requestId: requestId,
        entryKey: entryKey,
        groupCode: groupCode,
        stockCode: stockCode,
        needDetail: needDetail || false,
    };
    return Axios.post('/instruction/inst/branchResult', param);
}

/**
 * 试算
 */
export function trialCalculate(data): Promise<any> {
    return Axios({
        url: '/dataEngine/trialCalculate',
        method: 'post',
        data: data,
    });
}

/**
 * 撤销一级债下单
 */
export function cancelSeniorBondOrder(data): Promise<any> {
    return Axios.post('/dataEngine/order/seniorBond/cancelOrder/andDelete', data);
}

/**
 * 撤销普通指令下单
 */
export function cancelCommonOrder(data): Promise<any> {
    return Axios.post('/dataEngine/order/cancelOrder/andDelete', data);
}

/**
 * 获取指令价格为空时的计算价格，下面是取值顺序
 * lastPrice: 最新价
 * openPrice: 开盘价
 * closePrice: 昨收盘价
 * facePrice: 面值
 * @param stockCode
 */
export function getMarketPrice(stockCode: string) {
    return Axios.post('/dataEngine/getStockPrice/' + stockCode);
}
